#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>

void merge(int* nums1, int m, int* nums2, int n)
{
    int n1 = 0;
    int n2 = 0;
    int size = m;
    while (n2 < n)
    {
        if (n1 == size)
        {
            nums1[n1] = nums2[n2];
            n1++;
            n2++;
            size++;
        }
        else if (nums1[n1] < nums2[n2])
            n1++;
        else
        {
            int end = size;
            for (; end > n1; end--)
                nums1[end] = nums1[end - 1];
            nums1[n1] = nums2[n2];
            n1++;
            n2++;
            size++;
        }
    }
    for (int i = 0; i < m + n; i++)
    {
        printf("%d ", nums1[i]);
    }
}

int main()
{
    int nums1[] = { 1, 2, 3 , 0, 0, 0};
    int nums2[] = { 2, 5, 6 };
    merge(nums1, 3, nums2, 3);
    return 0;
}